from django.conf.urls import url
from rest_framework.routers import DefaultRouter
from rest_framework_jwt.views import obtain_jwt_token

from meiduo_mall_admin.commodity import brand_views
from meiduo_mall_admin.commodity import channel_views
from meiduo_mall_admin.commodity import sku_image_views
from meiduo_mall_admin.commodity import spec_option_views
from meiduo_mall_admin.commodity import spec_views
from meiduo_mall_admin.commodity import spu_views
from meiduo_mall_admin.home_views import views
from meiduo_mall_admin.system import group_permissiom_views
from meiduo_mall_admin.system import permission_admin_views
from meiduo_mall_admin.system import system_views
from meiduo_mall_admin.user import user_views
from meiduo_mall_admin.commodity import sku_views
from meiduo_mall_admin.order import order_views

urlpatterns = [
    # home
    url(r'^authorizations/$', obtain_jwt_token),
    url(r'^statistical/total_count/$', views.UserTotalCountView.as_view()),
    url(r'^statistical/day_increment/$', views.UserIncrementCountView.as_view()),
    url(r'^statistical/day_active/$', views.UserActiveCountView.as_view()),
    url(r'^statistical/day_orders/$', views.UserDayOrderCountView.as_view()),
    url(r'^statistical/month_increment/$', views.UserMonthIncreamentCountView.as_view()),
    url(r'^statistical/goods_day_views/$', views.UserDAyView.as_view()),

    # user
    url(r'^users/$', user_views.UserView.as_view()),

    # SKU
    url(r'^skus/categories/$', sku_views.SKUCategoryView.as_view()),
    url(r'^goods/simple/$', sku_views.SKUSimpleView.as_view()),
    url(r'^goods/(?P<spu_id>\d+)/specs/$', sku_views.SKUGoodsSpecsView.as_view()),

    # SPU
    url(r'^goods/brands/simple/$', spu_views.SPUSimpleVIews.as_view()),
    url(r'^goods/channel/categories/$', spu_views.SPUCategoriesVIews.as_view()),
    url(r'^goods/channel/categories/(?P<category_id>\d+)/$', spu_views.SPUCategorySubView.as_view()),
    url(r'^goods/images/$', spu_views.SPUImagesView.as_view()),

    # specs/options
    url(r'^goods/specs/simple/$', spec_option_views.OptionViewSet.as_view()),

    # sku_image
    url(r'^skus/simple/$', sku_image_views.SKUImageViews.as_view({"get": "simple"})),

    # 权限类型
    url(r'^permission/content_types/$', system_views.PermissioTypenViews.as_view()),

    url(r'^permission/simple/$', group_permissiom_views.PermissionGroupViews.as_view()),

    # 获取组的数据表
    url(r'^permission/groups/simple/$', permission_admin_views.PermissionGroupAdminViews.as_view()),


    # 新增频道组
    url(r"^goods/channel_types/$", channel_views.GoodsChannelGroupViews.as_view()),
    url(r"^goods/categories/$", channel_views.GoodsChannelCategoryViews.as_view())

]

# goods/brands
router = DefaultRouter()
router.register(r"goods/brands", brand_views.BrandViews, base_name="brand")
urlpatterns += router.urls


# goods/categories
router = DefaultRouter()
router.register(r"goods/channels", channel_views.CategoriesViews, base_name="category")
urlpatterns += router.urls

# permission/admins
router = DefaultRouter()
router.register(r"permission/admins", permission_admin_views.PermissionAdminViews, base_name="admin")
urlpatterns += router.urls

# permission/groups
router = DefaultRouter()
router.register(r"permission/groups", group_permissiom_views.GroupsPermissionViews, base_name="permission_group")
urlpatterns += router.urls

# permission/perms
router = DefaultRouter()
router.register(r"permission/perms", system_views.PermissionViews, base_name="permission")
urlpatterns += router.urls

# ,orders
router = DefaultRouter()
router.register(r'orders', order_views.OrderViewSet, base_name="orders")
urlpatterns += router.urls

# skus/images
router = DefaultRouter()
router.register(r"skus/images", sku_image_views.SKUImageViews, base_name="specs")
urlpatterns += router.urls

# spec_optiom
router = DefaultRouter()
router.register(r"specs/options", spec_option_views.SpecOptionViewSet, base_name="specs")
urlpatterns += router.urls

# spec
router = DefaultRouter()
router.register(r"goods/specs", spec_views.SpecViewSet, base_name="specs")
urlpatterns += router.urls

# sku
router = DefaultRouter()
router.register(r"skus", sku_views.SKUViewSet, base_name="skus")
urlpatterns += router.urls

# spu
router = DefaultRouter()
router.register(r"goods", spu_views.SPUViewSet, base_name="spus")
urlpatterns += router.urls

print(urlpatterns)
